//
//  NSString+path.m
//  18-沙盒演练
//
//  Created by apple on 16/1/6.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "NSString+path.h"

@implementation NSString (path)

- (NSString *)appendCache
{
    // 获取cache文件路径
    NSString *path_cache = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject];
    // 截取图片的名字
    NSString *name_cache = [self lastPathComponent];
    // 拼接保存图片的沙盒路径
    NSString *file_cache = [path_cache stringByAppendingPathComponent:name_cache];
    
    return file_cache;
}

- (NSString *)appenddocuments
{
    // 获取documents文件路径
    NSString *path_doc = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    // 截取图片的名字
    NSString *name = [self lastPathComponent];
    // 拼接保存图片的沙盒路径
    NSString *file_doc = [path_doc stringByAppendingPathComponent:name];
    return file_doc;
}

- (NSString *)appendtmp
{
    NSString *tmp = [NSTemporaryDirectory() stringByAppendingPathComponent:[self lastPathComponent]];
    return tmp;
}

@end
